package com.ceair.mub2c.payment.payments.service.impl;

import java.math.BigDecimal;
import java.util.List;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ceair.mub2c.payment.payments.service.PurchasePointsDubboService;
import com.ceair.unified.businessobject.rqrs.exrate.ExRateRQ;
import com.ceair.unified.businessobject.rqrs.exrate.ExRateRS;
import com.ceair.unified.businessobject.rqrs.unicfg.UniChannelRS;
import com.ceair.unified.businessobject.rqrs.unicfg.UniCurrencyRS;
import com.ceair.unified.businessobject.vo.OutCurrencyVO;
import com.ceair.unified.ws.IExRateManagerWS.IExRateManagerWS;
import com.ceair.unified.ws.unicfgmanager.IUniConfigManagerWS;

@Service
public class PurchasePointsDubboServiceImpl implements PurchasePointsDubboService {

	Logger log = Logger.getLogger(getClass());
	@Autowired
	private IUniConfigManagerWS uniConfigManagerWS;
	@Resource(name = "exRateManagerWS")
	private IExRateManagerWS iExRateManagerWS;

	public Long getChannelCode(String site) {
		try {
			log.info("获取站点渠道CODE开始：当前站点：" + site);
			UniChannelRS rs = uniConfigManagerWS.findUniChannelBySite(site);
			if (rs.getMsgCode() != 0) {
				log.info("获取站点渠道CODE结束，返回渠道CODE为空!");
				return null;
			}
			log.info("获取站点渠道CODE结束，返回渠道CODE" + rs.getChannel());
			return rs.getChannel();
		} catch (Exception e) {
			log.error("获取站点渠道CODE失败，异常信息：" + e.getMessage());
			throw new RuntimeException(e);
		}
	}

	public String getCurrencyCode(Long channel) {
		try {
			log.info("获取币种CODE开始：当前渠道CODE：" + channel);
			UniCurrencyRS rs = uniConfigManagerWS.findCurrencyAndSgByChannel(channel);
			if (rs.getMsgCode() != 0) {
				log.info("获取币种CODE结束，返回币种CODE为空!");
				return null;
			}
			log.info("获取币种CODE结束，返回币种CODE" + rs.getCurrency());
			return rs.getCurrency();
		} catch (Exception e) {
			log.error("获取币种CODE失败，异常信息：" + e.getMessage());
			throw new RuntimeException(e);
		}
	}
}
